﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Campus.Main.Basic.InsertValues;
using cpmntctrl;
using dbcntn;

namespace Campus.Main.Basic.Settings
{
    public partial class NationForm : DefaultForm
    {
        public NationForm()
        {
            InitializeComponent();
            aToDb=new ConnectionToDb(Helper.ConnectionString);
            Initialize();
        }

        public override void Initialize()
        {
            aToDb.AddItemDBGridView(dataGridView1,Query.Nation);
            ControlComponent.UnVisibleCells(dataGridView1,0);
            textBox1.Clear();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length>0)
            {
                aToDb.InsertIntoTable("nation","description",textBox1.Text);
                Initialize();
            }
            else
            {
                MessageBox.Show("Талааны толтургула!!!");
            }
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var data = new List<string>();
            ControlComponent.AddToList(data,dataGridView1,e,0,1);
            Nation f=new Nation(data);
            f.FormClosed += Bind;
            f.ShowDialog();
        }

        private new void Bind(object sender, FormClosedEventArgs e)
        {
            Initialize();
        }
    }
}
